package rs.udd.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import rs.udd.model.Advertiser;
import rs.udd.model.Agent;

public interface AdvertiserRepository extends JpaRepository<Advertiser, Long> {

	public Advertiser findByUsername(String username);

	@Query("SELECT a FROM Advertiser a JOIN a.hiddenByAgents agent WHERE agent != :agent")
	// FIXME advertisers not hidden by agent
	public List<Advertiser> findAllAdvertisersShownByAgent(@Param("agent") Agent agent);

}
